<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Controle de Agenda</title>
	<link rel="stylesheet" type="text/css" href="css/tabela.css" />
</h:head>
<ui:composition template="/Menu.xhtml">
	<ui:define name="corpo">
		<h:body>
			<f:view encoding="ISO-8859-1">
				<h:form id="controleAgenda">
					<h:messages layout="table" errorStyle="color: red"
						infoStyle="color: green" warnStyle="color: orange"
						fatalStyle="color: gray" showDetail="true" />
					<h4>Controle de Agenda</h4>

					<h:outputText value="Nome Usuário" />
					<h:selectOneMenu style="width:300px"
						value="#{controleAgenda.usuario.login}"
						disabled="#{not login.usuario.admin}">
						<f:selectItems value="#{controleAgenda.usuarios}" var="u"
							itemLabel="#{u.nome}" itemValue="#{u.login}" />
					</h:selectOneMenu>

					<!-- 
					<h:panelGrid columns="2">
						<h:outputText value="Nome" />
						<h:inputText value="#{agenda.rdv.tipo}" />
						<h:outputText value="Data Inicial" />
						<h:inputText value="#{agenda.rdv.dataInicial}">
							<f:convertDateTime pattern="dd/MM/yyyy"
								timeZone="#{initParam.timezone}" />
						</h:inputText>
						<h:outputText value="Data Final" />
						<h:inputText value="#{agenda.rdv.dataFinal}">
							<f:convertDateTime pattern="dd/MM/yyyy"
								timeZone="#{initParam.timezone}" />
						</h:inputText>
						<h:outputText value="Liberado" />
						<h:selectBooleanCheckbox value="#{agenda.rdv.liberado}" />
					</h:panelGrid>
					<br />
					<h:commandButton styleClass="g-button g-button-submit"
						action="#{agenda.salvar}" value="SALVAR" style="width:150px" />
					<h:commandButton styleClass="g-button g-button-submit"
						action="#{agenda.novo}" value="NOVO" style="width:150px" />
					<br />
					<br />
					<h4>Consultar</h4>
					-->
					<h:panelGrid columns="2">
						<h:outputText value="RDV" />
						<h:selectOneMenu value="#{controleAgenda.tipoId}">
							<f:selectItems value="#{controleAgenda.tipos}" var="t"
								itemLabel="#{t.tipo}" itemValue="#{t.id}" />
						</h:selectOneMenu>
					</h:panelGrid>
					<br />
					<h:commandButton styleClass="g-button g-button-submit"
						action="#{controleAgenda.consultar}" value="CONSULTAR"
						style="width:150px" />
					<br />
					<br />
					<p:dataTable id="tableAgenda" var="agenda"
						value="#{controleAgenda.listaAgenda}" editable="true">

						<p:column headerText="Data" width="100px">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{agenda.data}" style="width:100%">
										<f:convertDateTime pattern="dd/MM/yyyy (EE)" />
									</h:outputText>
								</f:facet>
								<f:facet name="input">
									<h:outputText value="#{agenda.data}" style="width:100%">
										<f:convertDateTime pattern="dd/MM/yyyy (EE)" />
									</h:outputText>
								</f:facet>
							</p:cellEditor>
						</p:column>
						<p:column headerText="Local">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{agenda.local}" />
								</f:facet>
								<f:facet name="input">
									<p:inputText value="#{agenda.local}" style="width:100%" />
								</f:facet>
							</p:cellEditor>
						</p:column>
						<p:column headerText="Ação Prevista">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{agenda.acaoPrevista}" />
								</f:facet>
								<f:facet name="input">
									<p:inputText value="#{agenda.acaoPrevista}" style="width:100%" />
								</f:facet>
							</p:cellEditor>
						</p:column>
						<p:column headerText="Ação Realizada">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{agenda.acaoRealizada}" />
								</f:facet>
								<f:facet name="input">
									<p:inputText value="#{agenda.acaoRealizada}" style="width:100%" />
								</f:facet>
							</p:cellEditor>
						</p:column>
						<p:column style="width:32px">
							<p:rowEditor />
						</p:column>
						<p:ajax event="rowEdit" listener="#{controleAgenda.onRowEdit}" />
						<p:ajax event="rowEditCancel"
							listener="#{controleAgenda.onRowCancel}" />
					</p:dataTable>
				</h:form>
			</f:view>
		</h:body>
	</ui:define>
</ui:composition>
</html>